﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        if(!IsPostBack) {
            TarreOA.TarreOAModels.User u = (User) Session["user"];
            List<Popedom> n1 = new List<Popedom>();
            List<Popedom> n2 = new List<Popedom>();
            List<Popedom> n3 = new List<Popedom>();

            foreach(Popedom var in u.PopedomGroup.PopedomList) {
                if(var.Level == 1) {
                    n1.Add(var);
                } else if(var.Level == 2) {
                    n2.Add(var);
                } else if(var.Level == 3) {
                    n3.Add(var);
                }
            }
            TreeNode tn = new TreeNode("全部展开");
            TreeView1.Nodes.Add(tn);
            foreach(Popedom var in n1) {
                TreeNode tn1 = new TreeNode(var.PopedomName);
                tn1.ImageUrl = "images/menu/" + var.ImagePath + ".gif";
                tn1.Target = "s1";
                tn1.NavigateUrl = var.Url;
                tn.ChildNodes.Add(tn1);
                foreach(Popedom p2 in n2) {
                    if(p2.BaseNode == var.PopedomId) {
                        TreeNode tn2 = new TreeNode(p2.PopedomName);
                        tn2.ImageUrl = @"images/menu/" + p2.ImagePath + ".gif";
                        tn2.Target = "s1";
                        tn2.NavigateUrl = p2.Url;
                        tn1.ChildNodes.Add(tn2);
                        foreach(Popedom p3 in n3) {
                            if(p3.BaseNode == p2.PopedomId) {
                                TreeNode tn3 = new TreeNode(p3.PopedomName);
                                tn3.ImageUrl = @"images/menu/" + p3.ImagePath + ".gif";
                                tn3.Target = "s1";
                                tn3.NavigateUrl = p3.Url;
                                tn2.ChildNodes.Add(tn3);
                            }
                        }
                    }
                }
            }
            TreeView1.CollapseAll();
            TreeView1.Nodes[0].Expand();
        }
    }
}
